I am trying to dynamically create titles for a graph by referencing sub-strings from a macro list. Some of these strings contain multiple words. Intuitively, I tried the following:
However, Stata seems to interpret the first (and only the first) macro of the list "Mining, Water, & Energy" as separate words, giving me the following output:
There must be a simple reason why this works with later sub-macros such as "Health & Education", but not with the first one. Perhaps the `: word ...' syntax isn't the best way to achieve this in the first place?
Code:
local industries_string "Mining, Water & Energy" "Manufacturing" "Health & Education" "Construction" "Retail" "Transportation & Communication" "Hospitality & Food" "Arts & Other Services" "Finance" "Professional Services" "Administration" "Public Services"
forvalues i=1/12{
local industry_string `: word `i' of `industries_string''
di "`industry_string'"
}
Code:
. local industries_string "Mining, Water & Energy" "Manufacturing" "Health & Education" "Construction" "Retail" "Transportation &
> Communication" "Hospitality & Food" "Arts & Other Services" "Finance" "Professional Services" "Administration" "Public Service
> s"
.
. forvalues i=1/12{
2. local industry_string `: word `i' of `industries_string''
3. di "`industry_string'"
4. }
Mining,
Water
&
Energy
Manufacturing
Health & Education
Construction
Retail
Transportation & Communication
Hospitality & Food
Arts & Other Services
Finance

Comment